package org.rule.function;

import cn.hutool.core.util.StrUtil;
import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.function.FunctionUtils;
import com.googlecode.aviator.runtime.type.AviatorBoolean;
import com.googlecode.aviator.runtime.type.AviatorLong;
import com.googlecode.aviator.runtime.type.AviatorObject;
import com.googlecode.aviator.runtime.type.AviatorType;

import java.math.BigDecimal;
import java.util.Map;

public class NumEqualFunction extends AbstractFunction{
    @Override
    public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
        Object obj1 = arg1.getValue(env).toString();
        Object obj2 = arg2.getValue(env).toString();
        BigDecimal b1 = new BigDecimal(String.valueOf(obj1));
        BigDecimal b2 = new BigDecimal(String.valueOf(obj2));
        return AviatorLong.valueOf(b1.compareTo(b2));
    }
    @Override
    public String getName() {
        return "num_equal";
    }
}
